package com.xyht.sca_s.student_manage_system.modules.common.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.common.entity.req.SmsApplyDraftReq;
import com.xyht.sca_s.student_manage_system.modules.common.service.SmsApplyDraftService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 申请表草稿箱 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-06-20
 */
@RestController
@RequestMapping("/common/smsApplyDraft")
@SecretBody
public class SmsApplyDraftController {
    @Autowired
    private SmsApplyDraftService smsApplyDraftService;
    @Autowired
    private JwtTokenUtil jwtTokenUtil;

    @PostMapping("/add")
    @ApiModelProperty(value = "添加草稿箱")
    public ResponseResult addApplyDraft(@RequestBody SmsApplyDraftReq smsApplyDraftReq, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsApplyDraftService.addApplyDraft(smsApplyDraftReq,user_id);
    }

    @GetMapping("/get")
    @ApiModelProperty(value = "获取草稿箱")
    public ResponseResult getOwnApplyDraft(@RequestParam("appType") String appType, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsApplyDraftService.getOwnApplyDraft(appType,user_id);
    }

    @PostMapping("/delete")
    @ApiModelProperty(value = "删除草稿箱")
    public ResponseResult deleteApplyDraft(@RequestBody SmsApplyDraftReq smsApplyDraftReq){
        return smsApplyDraftService.deleteApplyDraft(smsApplyDraftReq);
    }
}

